home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / teco.zip / TYPE.C < prev    next >
C/C++ Source or Header  |  1986-07-15  |  1KB  |  52 lines

  1. #include <ctype.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. type()
  6. {
  7. #include "teco.h"
  8.  
  9.     int tmp;                /* First  scratch */
  10.     int wrk;                /* Second scratch */
  11.  
  12.     tmp=bufptx;                /* Save context   */
  13.     if (number < 1) while (1) {        /* Position back  */
  14.         if (!tmp) {
  15.             while (++tmp <= bufptx) {
  16.                 echo(buffer[tmp]);
  17.             }
  18.             return;            /* All done  type */
  19.         }
  20.         if (toascii(buffer[--tmp]) == 13) {
  21.             if (! number++){/* Start new line */
  22.                 if (toascii(buffer[++tmp]) == 10){
  23.                     tmp++;
  24.                 }
  25.                 while(tmp <= bufptx) {
  26.                     echo(buffer[tmp++]);
  27.                 }
  28.                 return;        /* All done  type */
  29.             }
  30.         }
  31.     }
  32.     if (number > 0) while (1) {        /* Type out stuff */
  33.         if (tmp > bufptr) {        /* Type out stuff */
  34.             wrk=bufptx;
  35.             while (++wrk <= bufptr) {
  36.                 echo(buffer[wrk]);
  37.             }
  38.             return;            /* All done  type */
  39.         }
  40.         if (toascii(buffer[++tmp]) == 13) {
  41.             if (toascii(buffer[tmp]) == 10) ++tmp;
  42.             if (! --number) {
  43.                 wrk=bufptx;
  44.                 while (wrk++ < tmp) {
  45.                     echo(buffer[wrk]);
  46.                 }
  47.                 return;        /* All done  type */
  48.             }
  49.         }
  50.     }
  51. }
  52.